﻿CREATE VIEW dbo.v_State_WithParams
AS
SELECT     dbo.v_State.ID, dbo.v_State.TableName, PARAM_OnRowClick.StateParameterValue AS OnRowClick, 
                      PARAM_OnRowClick_Parent.StateParameterValue AS OnRowClick_Parent, dbo.v_State.Name, dbo.v_State.NameLong, dbo.v_State.Nick, 
                      dbo.v_State.Description, dbo.v_State.Pos, dbo.v_State.ParentPos, dbo.v_State.StateFlowPos, dbo.v_State.IsMenu, 
                      ISNULL(NULLIF (dbo.v_State.OnClick, N''), STATE_PARENT.OnClick) AS OnClick, dbo.v_State.ParentID, dbo.v_State.ParentName, dbo.v_State.Target, 
                      dbo.v_State.Style, dbo.v_State.Icon, ISNULL(PARAM_SelectList.StateParameterValue, PARAM_SelectList_Parent.StateParameterValue) AS SelectList, 
                      PARAM_SelectViewName.StateParameterValue AS SelectViewName, CONVERT(int, ISNULL(PARAM_PageSize.StateParameterValue, 25)) AS PageSize, 
                      CONVERT(bit, ISNULL(P_IsManaged.StateParameterValue, 0)) AS IsManaged, CONVERT(int, ISNULL(P_ApplLockTO.StateParameterValue, 0)) 
                      AS ApplLockTimeOut, CONVERT(varchar(256), PARAM_JScript.StateParameterValue) AS JScript
FROM         dbo.v_State INNER JOIN
                      dbo.t_State AS STATE_PARENT ON dbo.v_State.ParentID = STATE_PARENT.ID LEFT OUTER JOIN
                      dbo.t_State_Parameters AS PARAM_JScript ON dbo.v_State.ID = PARAM_JScript.StateID AND 
                      PARAM_JScript.StateParameterID = dbo.fs_StateParamID__JScript() LEFT OUTER JOIN
                      dbo.t_State_Parameters AS P_ApplLockTO ON dbo.v_State.ID = P_ApplLockTO.StateID AND 
                      P_ApplLockTO.StateParameterID = dbo.fs_StateID__StateParameter__ApplLockTimeOut() LEFT OUTER JOIN
                      dbo.t_State_Parameters AS P_IsManaged ON dbo.v_State.ID = P_IsManaged.StateID AND 
                      P_IsManaged.StateParameterID = dbo.fs_StateID__StateParameter__IsManaged() LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_SelectViewName ON dbo.v_State.ID = PARAM_SelectViewName.StateID AND 
                      PARAM_SelectViewName.StateParameter = N'Select View Name' LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_SelectList_Parent ON dbo.v_State.ParentID = PARAM_SelectList_Parent.StateID AND 
                      PARAM_SelectList_Parent.StateParameter = 'Select List' LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_SelectList ON dbo.v_State.ID = PARAM_SelectList.StateID AND 
                      PARAM_SelectList.StateParameter = 'Select List' LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_OnRowClick_Parent ON dbo.v_State.ParentID = PARAM_OnRowClick_Parent.StateID AND 
                      PARAM_OnRowClick_Parent.StateParameter = N'OnRowClick' LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_OnRowClick ON dbo.v_State.ID = PARAM_OnRowClick.StateID AND 
                      PARAM_OnRowClick.StateParameter = N'OnRowClick' LEFT OUTER JOIN
                      dbo.v_State_Parameters AS PARAM_PageSize ON dbo.v_State.ID = PARAM_PageSize.StateID AND PARAM_PageSize.StateParameter = N'Page Size'

GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[39] 4[31] 2[21] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "v_State"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 114
               Right = 189
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "STATE_PARENT"
            Begin Extent = 
               Top = 235
               Left = 323
               Bottom = 343
               Right = 474
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_JScript"
            Begin Extent = 
               Top = 6
               Left = 576
               Bottom = 99
               Right = 758
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "P_ApplLockTO"
            Begin Extent = 
               Top = 336
               Left = 765
               Bottom = 429
               Right = 947
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "P_IsManaged"
            Begin Extent = 
               Top = 230
               Left = 507
               Bottom = 323
               Right = 689
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_SelectViewName"
            Begin Extent = 
               Top = 429
               Left = 440
               Bottom = 537
               Right = 649
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_SelectList_Parent"
            Begin Extent = 
               Top = 188
               Left = 292
               Bottom = 296
               Right = 501', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_State_WithParams';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_SelectList"
            Begin Extent = 
               Top = 330
               Left = 38
               Bottom = 438
               Right = 247
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_OnRowClick_Parent"
            Begin Extent = 
               Top = 438
               Left = 38
               Bottom = 546
               Right = 247
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_OnRowClick"
            Begin Extent = 
               Top = 546
               Left = 38
               Bottom = 654
               Right = 247
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "PARAM_PageSize"
            Begin Extent = 
               Top = 654
               Left = 38
               Bottom = 762
               Right = 247
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 24
         Width = 284
         Width = 1500
         Width = 1080
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 5610
         Alias = 1605
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 660
         SortOrder = 750
         GroupBy = 1350
         Filter = 3885
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_State_WithParams';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_State_WithParams';

